home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / wink24h / src / disp.c < prev    next >
Text File  |  1994-06-01  |  4KB  |  159 lines

  1. #include    <stdlib.h>
  2. #include    <ctype.h>
  3. #include    "defs.h"
  4.  
  5. #define    PAGE0    0
  6. #define    PAGE1    0x40000
  7.  
  8. extern short ReWrt_flg;
  9. extern int   MAX_SCR;
  10.  
  11. extern void wrtank(int ch,int x,int y,int fc,int bc,int of);
  12. extern void wrtkan(int ch,int x,int y,int fc,int bc,int of);
  13. extern void disp_cur(int x,int y,int of);
  14. extern void memcpy();
  15. extern void memset();
  16.  
  17. UCHAR *dmy_vram=(UCHAR *)NULL;
  18.  
  19. /************************
  20. void    wrtstr(str,x,y,cl)
  21. unsigned char    *str;
  22. int    x,y,cl;
  23. {
  24.     int        fc,bc;
  25.     register UCHAR  *mp;
  26.  
  27.     if ( (cl & 0x10) != 0 ) {
  28.         bc = cl & 0x0F; fc = 0;
  29.     } else {
  30.         fc = cl & 0x0F; bc = 0;
  31.     }
  32.  
  33.     mp = dmy_vram + (x * 2 + y * (MAX_X * 2));
  34.     while ( *str != '\0' ) {
  35.     if ( iskanji(*str) && iskanji2(*(str+1)) ) {
  36.         wrtkan((*str << 8) | *(str+1),x,y,fc,bc,PAGE0);
  37.         *(mp++) = cl | 0x40;
  38.         *(mp++) = *(str++);
  39.         *(mp++) = cl | 0x80;
  40.         *(mp++) = *(str++);
  41.         x += 2;
  42.     } else if ( *str == '\x1B' ) {
  43.         str++;
  44.     } else {
  45.         wrtank(*str,x,y,fc,bc,PAGE0);
  46.         *(mp++) = cl;
  47.         *(mp++) = *(str++);
  48.         x++;
  49.     }
  50.     if ( x >= MAX_X ) {
  51.        y++; x = 0;
  52.     }
  53.     }
  54. }
  55. *********************************/
  56. void    locate()
  57. {
  58.     UCHAR  *vp;
  59.     vp = (dmy_vram + (Cur_X + OFF_X) * 2 + (Cur_Y + OFF_Y) * (MAX_X * 2));
  60.     *vp |= 0x20;
  61.     disp_cur(Cur_X + OFF_X,Cur_Y + OFF_Y,PAGE0);
  62. }
  63. /***************************************
  64. void    Dsp_vram(vp)
  65. register UCHAR    *vp;
  66. {
  67.     int     x,y;
  68.     int     ch,fc,bc;
  69.     register UCHAR  *mp;
  70.  
  71.     mp = dmy_vram + (OFF_X * 2 + OFF_Y * (MAX_X * 2));
  72.     for ( y = 0 ; y < MAX_SCR ; y++ ) {
  73.     for ( x = 0 ; x < MAX_X ; x++,vp+=2,mp+=2 ) {
  74.         if ( *vp != *mp || *(vp+1) != *(mp+1) ) {
  75.         if ( x > 0 && (*vp & 0x80) != 0 && (*(vp-2) & 0x40) != 0 ) {
  76.             x--; vp-=2; mp-=2;
  77.         }
  78.         if ( (*vp & 0x10) != 0 ) {
  79.             bc = *vp & 0x0F;
  80.             fc = 0;
  81.         } else {
  82.             fc = *vp & 0x0F;
  83.                 bc = 0;
  84.         }      
  85.         if ( (*vp & 0x40) != 0 && (*(vp+2) & 0x80) != 0 ) {
  86.             ch = (*(vp+1) << 8) | *(vp+3);
  87.             wrtkan(ch,x + OFF_X,y + OFF_Y + offset,fc,bc,PAGE0);
  88.             memcpy(mp,vp,4);
  89.         } else {
  90.             wrtank(*(vp+1),x + OFF_X,y + OFF_Y + offset,fc,bc,PAGE0);
  91.             memcpy(mp,vp,2);
  92.         }
  93.         }
  94.     }
  95.     }
  96.     ReWrt_flg = ERR;
  97.     locate();
  98. }
  99. *****************************************/
  100. void    Dsp_vram_flash()
  101. {
  102. /*
  103.     memset(dmy_vram,0xFF,MAX_X*MAX_Y*2);
  104. */
  105. }
  106. void    Dsp_init()
  107. {
  108.     dmy_vram = (unsigned char *)malloc(MAX_X*(MENU_Y+1)*2);
  109.     memset(dmy_vram,0,MAX_X*(MENU_Y+1)*2);
  110. }
  111. UCHAR    *Act_vram()
  112. {
  113.     return (dmy_vram + (OFF_X + Cur_X) * 2 + (OFF_Y + Cur_Y) * (MAX_X * 2));
  114. }
  115. void    Dsp_box_vram(ct,bak)
  116. int    ct,bak;
  117. {
  118.     int     ch,y,x,bc,fc,bb;
  119.     UCHAR   *vp;
  120.  
  121.     vp = (dmy_vram + (OFF_X + Cur_X) * 2 + (OFF_Y + Cur_Y) * (MAX_X * 2));
  122.     y = OFF_Y + Cur_Y; x = OFF_X + Cur_X;
  123.     while ( ct-- > 0 ) {
  124.     if ( (*vp & 0x20) != 0 )
  125.         bb = bak;
  126.     else
  127.         bb = 0;
  128.     if ( (*vp & 0x10) != 0 ) {
  129.         bc = *vp & 0x0F;
  130.         fc = bb;
  131.     } else {
  132.         fc = *vp & 0x0F;
  133.             bc = bb;
  134.     }
  135.     if ( bc != 0 && fc == bc )
  136.         fc = 0;      
  137.     if ( (*vp & 0x40) != 0 && (*(vp+2) & 0x80) != 0 ) {
  138.         if ( x == (MAX_X-1) ) {
  139.             wrtank(0xFE,x,y,fc,bc,PAGE0);
  140.             wrtank(0xFE,OFF_X,y+1,fc,bc,PAGE0);
  141.         } else {
  142.             ch = (*(vp+1) << 8) | *(vp+3);
  143.             wrtkan(ch,x,y,fc,bc,PAGE0);
  144.         }
  145.         x++; vp += 4; ct--;
  146.     } else if ( (*vp & 0x80) != 0 ) {
  147.         wrtank(0x20,x,y,fc,bc,PAGE0);
  148.         vp += 2;
  149.     } else {
  150.         wrtank(*(vp+1),x,y,fc,bc,PAGE0);
  151.         vp += 2;
  152.     }
  153.     if ( ++x >= MAX_X ) {
  154.         x = OFF_X;
  155.         y++;
  156.     }
  157.     }
  158. }
  159.